import java.util.Scanner;

public class demo1 {
    public static void main(String[] args) {
        //给定两个变量 为用户名和密码
        String rightUserName = "chenchen";
        String rightUserWord = "zhang123456";

        for (int i = 0; i < 3; i++) {
            //键盘输入

            Scanner sc = new Scanner(System.in);
            System.out.println("请输入用户名");
            String s1 = sc.next();
            System.out.println("请输入密码");
            String s2 = sc.next();
            //比较正确
            if ((s1.equals(rightUserName)) && (s2.equals(rightUserWord))) {
                System.out.println("登录成功");
                break;
            } else {
                if (i == 2) {
                    System.out.println("账号登录失败,已被锁定，练习官方客服");
                } else {
                    System.out.println("登录失败,您还有" + (2 - i) + "次机会");
                }
            }

        }

    }
}
